package com.examplemartin.jpademo.service.sell;

import com.examplemartin.jpademo.dao.SellDetailDao;
import com.examplemartin.jpademo.pojo.po.sell.SellDetailPO;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

@Service
@Component
public class SellDetailService {
    @Resource
    private SellDetailDao sellDetailDao;

    public SellDetailPO save(SellDetailPO sellDetailPO){
        return sellDetailDao.save(sellDetailPO);
    }

    public void deleteById(Long id) {
        sellDetailDao.deleteById(id);
    }

    public void delete(SellDetailPO sellDetailPO){
        sellDetailDao.delete(sellDetailPO);
    }

    public SellDetailPO findById(Long id) {
        Optional<SellDetailPO> byId = sellDetailDao.findById(id);
        if(byId!=null){
            return byId.get();
        }else {
            return null;
        }
    }
}
